//
//  KSFormItemAppearance.swift
//  ZYA
//
//  Created by 邱仙凯 on 2021/11/15.
//  Copyright © 2021 aowang. All rights reserved.
//

import UIKit
 
let ItemHHeight:CGFloat = 43 // 单个普通控件的高度
let ItemVHeight:CGFloat = 120 // 单个普通控件的高度 上下型

let BgLeading:CGFloat = 6 // 通用背景的左边距
let SeparateHeight:CGFloat = 5 // 间隔控件的高度

let ItemBtnHeight:CGFloat = 58 // 按钮控件的高度
let ItemCornerRadius:CGFloat = 8 // 圆角

class KSFormBaseAppear:NSObject {
    // 输入框带边框
    var border:Bool = false
     @discardableResult
    func border(_ value:Bool) -> KSFormBaseAppear {
        self.border = value
        return self
    }
    
    // 禁用时，标题置灰，文本跟着置灰     默认否（默认文本还是黑的）
    var disableStyleContentGray:Bool = false
     @discardableResult
    func disableStyleContentGray(_ value:Bool) -> KSFormBaseAppear {
        self.disableStyleContentGray = value
        return self
    }
    
    // 输入框宽度
    var contentLabWidth:Int? = nil
     @discardableResult
    func contentLabWidth(_ value:Int) -> KSFormBaseAppear {
        self.contentLabWidth = value
        return self
    }
    // placeholder
    var placeholder:String? = nil
     @discardableResult
    func placeholder(_ value:String) -> KSFormBaseAppear {
        self.placeholder = value
        return self
    }
  
 
    // 标题正常状态颜色
   var tpTitleColor:UIColor = .black
    @discardableResult
   func tpTitleColor(_ value:UIColor) -> KSFormBaseAppear {
       self.tpTitleColor = value
       return self
   }
    // 标题背景色
   var tpTitleBgColor:UIColor = .clear
    @discardableResult
   func tpTitleBgColor(_ value:UIColor) -> KSFormBaseAppear {
       self.tpTitleBgColor = value
       return self
   }
    
     // 输入文本颜色
    var contentColor:UIColor = .black
     @discardableResult
    func contentColor(_ value:UIColor) -> KSFormBaseAppear {
        self.contentColor = value
        return self
    }
    
    // 输入文本大小
    var contentFont:UIFont = UIFont.systemFont(ofSize: 16)
    @discardableResult
   func contentFont(_ value:UIFont) -> KSFormBaseAppear {
       self.contentFont = value
       return self
   }
    // 整个item背景
    var itembgColor:UIColor = UIColor.white
     @discardableResult
    func itembgColor(_ value:UIColor) -> KSFormBaseAppear {
        self.itembgColor = value
        return self
    }
    
    // textview的背景色  默认有淡灰色，显示可输入区域
    var textBgColor:UIColor = UIColor(kshex:"#f8f8f8")
     @discardableResult
    func textBgColor(_ value:UIColor) -> KSFormBaseAppear {
        self.textBgColor = value
        return self
    }
    
    // 右边辅助图标str
    var assistImgStr:String?
     @discardableResult
    func assistImgStr(_ value:String) -> KSFormBaseAppear {
        self.assistImgStr = value
        return self
    }
    //  右边的描述文字  和右边辅助图标不同时出现
    var tailDesc:String?
    @discardableResult
    func tailDesc(_ value:String) -> KSFormBaseAppear {
        self.tailDesc = value
         return self
    }
 
    // 输入电话，非负数 ，无小数点
    var phoneInput:Bool = false
      @discardableResult
    func phoneInput(_ value:Bool) -> KSFormBaseAppear {
        self.phoneInput = value
         return self
    }
    
    // 植入正则表达式
    var regularExp:String = ""
    @discardableResult
    func regularExp(_ value:String) -> KSFormBaseAppear {
        self.regularExp = value
         return self
    }
    
    // 两位小数点的数字
    var twoDemiInput:Bool = false
    @discardableResult
    func twoDemiInput(_ value:Bool) -> KSFormBaseAppear {
        self.twoDemiInput = value
         return self
    }
    
      // 三位小数点的数字
      var threeDemiInput:Bool = false
      @discardableResult
      func threeDemiInput(_ value:Bool) -> KSFormBaseAppear {
          self.threeDemiInput = value
           return self
      }
    // 4位小数点的数字
    var fourDemiInput:Bool = false
    @discardableResult
    func fourDemiInput(_ value:Bool) -> KSFormBaseAppear {
        self.fourDemiInput = value
         return self
    }
    // 整数输入
    var integerInput:Bool = false
    @discardableResult
    func integerInput(_ value:Bool) -> KSFormBaseAppear {
        self.integerInput = value
         return self
    }
 
    // 密码输入
    var secureEntry:Bool = false
    @discardableResult
    func secureEntry(_ value:Bool) -> KSFormBaseAppear {
        self.secureEntry = value
         return self
    }
    
    // 必填（涉及*号显示，表单非空校验）
    var mustInput:Bool = false
    @discardableResult
    func mustInput(_ value:Bool) -> KSFormBaseAppear {
        self.mustInput = value
         return self
    }
    
    // 两位小数点的数字  允许负号
    var  negativeTwoDemiInput:Bool = false
    @discardableResult
    func negativeTwoDemiInput(_ value:Bool) -> KSFormBaseAppear {
        self.negativeTwoDemiInput = value
         return self
    }
    
    // 内容的右边距
    var contentTrailing:CGFloat = 25
    @discardableResult
    func contentTrailing(_ value:CGFloat) -> KSFormBaseAppear {
        self.contentTrailing = value
         return self
    }
    // 箭头右边距
    var arrowTrailing:CGFloat = 3
    @discardableResult
    func arrowTrailing(_ value:CGFloat) -> KSFormBaseAppear {
        self.arrowTrailing = value
         return self
    }

 
    //  segment 的数据源
    var segTitleArr:[String]?
    @discardableResult
    func segTitleArr(_ value:[String]) -> KSFormBaseAppear {
        self.segTitleArr = value
         return self
    }
    //  segment 背景
    var segBg:UIColor?
    @discardableResult
    func segBg(_ value:UIColor) -> KSFormBaseAppear {
        self.segBg = value
         return self
    }
    
    var segWidth:CGFloat = 80
    @discardableResult
    func segWidth(_ value:CGFloat) -> KSFormBaseAppear {
        self.segWidth = value
         return self
    }
    var titleFont:UIFont?
    @discardableResult
    func titleFont(_ value:UIFont) -> KSFormBaseAppear {
        self.titleFont = value
         return self
    }
    
    //  提示内容
    var tipStr:String?
    var tipFont:UIFont?
    var tipColor:String?
    var tipAligment:NSTextAlignment?
    @discardableResult
    func tipStr(_ tipStr:String,tipFont:UIFont? = nil ,tipColor:String? = nil ,tipAligment:NSTextAlignment? = nil) -> KSFormBaseAppear {
        self.tipStr = tipStr
        self.tipFont = tipFont
        self.tipColor = tipColor
        self.tipAligment = tipAligment
         return self
    }
    //  自定义的高度 高度
    var contentHight:CGFloat = ItemHHeight
    @discardableResult
    func contentHight(_ value:CGFloat) -> KSFormBaseAppear {
        self.contentHight = value
         return self
    }
    //  圆角
    var roundType:KSRoundType = .never
    @discardableResult
    func roundType(_ value:KSRoundType) -> KSFormBaseAppear {
        self.roundType = value
         return self
    }
   
    //  多选的数组
    var selectConArr:[String]?
    @discardableResult
    func selectConArr(_ value:[String]) -> KSFormBaseAppear {
        self.selectConArr = value
         return self
    }
    //  多选的数组颜色
    var selectColorArr:[UIColor]?
    @discardableResult
    func selectColorArr(_ value:[UIColor]) -> KSFormBaseAppear {
        self.selectColorArr = value
         return self
    }
    
    // 自动右箭头
    var autoArrow:Bool = true
    @discardableResult
    func autoArrow(_ value:Bool) -> KSFormBaseAppear {
        self.autoArrow = value
         return self
    }
     
    var limitTextCount: Int = 0
    @discardableResult
    func limitTextCount(_ count: Int) -> KSFormBaseAppear {
        self.limitTextCount = count
        return self
    }
    
    var overTextCountAlert: Bool = false
    @discardableResult
    func overTextCountAlert(_ isShow: Bool) -> KSFormBaseAppear {
        self.overTextCountAlert = isShow
        return self
    }
    
    var isEditAndActionBoth: Bool = false
    @discardableResult
    func isEditAndActionBoth(_ both: Bool) -> KSFormBaseAppear {
        self.isEditAndActionBoth = both
        return self
    }
 }
